package org.example.fboot.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;
import org.example.fboot.config.LocalDateTimeConverter;

import java.time.LocalDateTime;

@Data
@TableName(value = "user")
public class User {


    @Setter(AccessLevel.NONE)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @NotNull(message = "不能为空")
    @TableField(value = "username")
    private String username;

    @NotNull(message = "不能为空")
    @TableField(value = "password")
    private String password;
    /**
     * 状态
     */
    @TableField(value = "status")
    private long status;

    @JsonSerialize(using = LocalDateTimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "exp_datetime")
    private LocalDateTime expDatetime;

    @JsonSerialize(using = LocalDateTimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",  timezone = "GMT+8")
    @TableField(value = "update_datetime")
    private LocalDateTime updateDatetime;

    @JsonSerialize(using = LocalDateTimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "create_datetime")
    private LocalDateTime createDatetime;

}
